package com.studentsystem.common;

import java.io.Serializable;

public class Result<T> implements Serializable {

    private static final long serialVersionUID = -712367123620682473L;

    private Integer code;

    private String message;

    private T data;

    public static <E> Result<E> success(E data) {
        return new Result<>(200, "操作成功", data);
    }

    public static <E> Result<E> fail(String msg, E data) {
        return new Result<>(444, msg, data);
    }

    public Result() {
    }

    public Result(Integer code, String message, T data) {
        this.code = code;
        this.message = message;
        this.data = data;
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }
}
